Don't cause watch fire deadlock by unconditionally rewriting the sysrq node.
authorcl349@firebug.cl.cam.ac.uk <cl349@firebug.cl.cam.ac.uk>
Tue, 13 Sep 2005 21:24:03 +0000 (21:24 +0000)
committercl349@firebug.cl.cam.ac.uk <cl349@firebug.cl.cam.ac.uk>
Tue, 13 Sep 2005 21:24:03 +0000 (21:24 +0000)
Signed-off-by: Christian Limpach <Christian.Limpach@cl.cam.ac.uk>
linux-2.6-xen-sparse/arch/xen/kernel/reboot.c

index 2358970468b92b1f5ed5714b0910b2efeb0f66e1..b6608cef497a9102472bb44c1d5531975dbfa7e4 100644 (file)
@@ -355,16 +355,26 @@ static void shutdown_handler(struct xenbus_watch *watch, const char *node)
 static void sysrq_handler(struct xenbus_watch *watch, const char *node)
 {
     char sysrq_key = '\0';
-    
+    int err;
+
+ again:
+    err = xenbus_transaction_start("control");
+    if (err)
+       return;
     if (!xenbus_scanf("control", "sysrq", "%c", &sysrq_key)) {
         printk(KERN_ERR "Unable to read sysrq code in control/sysrq\n");
-        return;
+       xenbus_transaction_end(1);
+       return;
     }
 
-    xenbus_printf("control", "sysrq", "%c", '\0');
+    if (sysrq_key != '\0')
+       xenbus_printf("control", "sysrq", "%c", '\0');
 
-    if (sysrq_key != '\0') {
+    err = xenbus_transaction_end(0);
+    if (err == -ETIMEDOUT)
+       goto again;
 
+    if (sysrq_key != '\0') {
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
         handle_sysrq(sysrq_key, NULL, NULL);
 #else